package com.example.springbootdemo.sevice;

import com.example.springbootdemo.constant.RabbitmqConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  rabbitmq接口
 * </p>
 *
 * @author yurenwei
 * @since 2023/9/6
 */
@Slf4j
@Service
public class RabbitmqService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送消息
     */
    public void sendMessage() {
        rabbitTemplate.convertAndSend(RabbitmqConstant.TEST_EXCHANGE_NAME,RabbitmqConstant.TEST_ROUTING_KEY,"测试消息");
    }
}
